//
//  MerchantListController.swift
//  ExpressManager
//
//  Created by yongkang on 2017/11/3.
//  Copyright © 2017年 sheng. All rights reserved.
//

import UIKit
import SnapKit

class MerchantListController: UIViewController,UITableViewDataSource,UITableViewDelegate {
    
    @IBOutlet weak var completeLabel: UILabel!
    
    @IBOutlet weak var outstandLabel: UILabel!

    @IBOutlet weak var cleanderImg: UIImageView!
    
    @IBOutlet weak var dateSelect: UITextField!
    
    @IBOutlet weak var orderTabview: UITableView!
    
    var scrrenHeight = UIScreen.main.bounds.height
    
    var horizontalLine: UIView! //分隔线

    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        initUI()
    }
    
    func initUI()  {

        self.cleanderImg.snp.makeConstraints { (make) in
            make.top.equalTo(10)
            make.width.equalTo(25)
            make.height.equalTo(25)
            make.right.equalTo(-15)
        }
        
        self.dateSelect.snp.makeConstraints { (make) in
            make.top.equalTo(10)
            make.width.equalTo(150)
            make.height.equalTo(25)
            make.centerY.equalTo(self.cleanderImg)
            make.right.equalTo(self.cleanderImg.snp.left).offset(-15)
        }

        self.completeLabel.snp.makeConstraints { (make) in
            make.top.equalTo(10)
            make.left.equalTo(15)
            make.height.equalTo(12)
        }

        self.outstandLabel.snp.makeConstraints { (make) in
            make.top.equalTo(self.completeLabel.snp.bottom).offset(5)
            make.left.equalTo(self.completeLabel)
            make.height.equalTo(12)
        }
        
        self.horizontalLine =  UIView()
        self.horizontalLine.backgroundColor = UIColor.lightGray
        self.view.addSubview(self.horizontalLine)
        self.horizontalLine.snp.makeConstraints { (make) -> Void in
            make.height.equalTo(0.5)
            make.left.equalTo(0)
            make.right.equalTo(0)
            make.top.equalTo(outstandLabel.snp.bottom).offset(10)
           
        }
        
        self.orderTabview.snp.makeConstraints { (make) in
            make.top.equalTo(self.horizontalLine.snp.bottom)
            make.left.equalTo(0)
            make.right.equalTo(0)
            make.height.equalTo(scrrenHeight - 30)
        }
        
        
        self.orderTabview.dataSource = self
        self.orderTabview.delegate = self
        let nib = UINib(nibName: String(describing: OrderCellTableViewCell.self), bundle: nil)
        self.orderTabview.register(nib, forCellReuseIdentifier: "orderItem")
        self.orderTabview?.estimatedRowHeight = 44.0
        self.orderTabview?.rowHeight = UITableViewAutomaticDimension
    }
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 2
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "orderItem", for: indexPath) as! OrderCellTableViewCell
        return cell
    }
    
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        print("第\(indexPath.row)行被点击了")
    }


    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
